package com.source.multithread.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.util.List;
import java.util.Map;

/**
 * @Author wengqy
 * @Date 2021/1/8
 */
public class AntotaionTest2 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {

        Class<GeneicTypeDemo> gene = (Class<GeneicTypeDemo>) Class.forName("com.source.multithread.annotation.GeneicTypeDemo");
        Method getStu = gene.getMethod("getStu", List.class, Map.class);

        Type[] types = getStu.getGenericParameterTypes();
        for (Type type : types) {
         //   System.out.println(type);
            if(type instanceof  ParameterizedType){
                Type[] actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
                for (Type argument : actualTypeArguments) {
                    System.out.println(argument);
                }
            }

        }

        System.out.println("88888888888888888888888888888888888888888888888888888 :" );
        Type genericReturnType = getStu.getGenericReturnType();
        System.out.println("genericReturnType :"+genericReturnType);
        if(genericReturnType instanceof  ParameterizedType){
            Type[] actualTypeArguments = ((ParameterizedType) genericReturnType).getActualTypeArguments();
            for (Type argument : actualTypeArguments) {
                System.out.println(argument);
            }
        }
     //   System.out.println("genericReturnType :"+genericReturnType);

    }
}


